// TimerSpy.cpp: implementation of the CTimerSpy class.
//
//////////////////////////////////////////////////////////////////////

//#include "stdafx.h"
#include "Global_Function.h"
#include "TimerSpy.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CTimerSpy::CTimerSpy()
{
	QueryPerformanceFrequency(&m_CpuFrq);
}

CTimerSpy::~CTimerSpy()
{

}

void CTimerSpy::StartSpy()
{
    QueryPerformanceCounter(&m_Start);
}

double CTimerSpy::GetElapseTime()
{
	//QueryPerformanceCounter(&m_Stop);
	double mEllipse=(double)(m_Stop.QuadPart-m_Start.QuadPart);
	if(m_CpuFrq.QuadPart!=0)
		mEllipse/=m_CpuFrq.QuadPart;
    return mEllipse;
}

double CTimerSpy::GetCurrentTimex()
{
	QueryPerformanceFrequency(&m_CpuFrq);
    QueryPerformanceCounter(&m_Start);
	if(m_CpuFrq.QuadPart!=0)
		return ((double)m_Start.QuadPart)/((double)m_CpuFrq.QuadPart);
    return 0;
}
